<?php
class Main_Validate_EqualInputs extends Zend_Validate_Abstract
{
    /**
     * @var const
     */
    const NOT_EQUAL = 'stringsNotEqual';

    /**
     * @var array
     */
    protected $_messageTemplates = array(
            self::NOT_EQUAL => 'Строки не совпали'
        );

    /**
     * @var string
     */
    protected $_contextKey;

    /**
     * @param string $key  
     * @param string $message  
     */
    public function __construct($key, $message = null)
    {
        $this->_contextKey = $key;
        if (!empty($message)) {
            $this->_messageTemplates[self::NOT_EQUAL] = $message;
        }
    }

    /**
     * @param string $value 
     * @param array $context
     * @return bool
     */
    public function isValid ($value, $context = null)
    {
    	if ($value == $context[$this->_contextKey]) {
    		return true;
    	}

        $this->_error(self::NOT_EQUAL);
        return false;
    }
}